package com.example.zz.example.java;


import android.os.Build;

import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeSet;

/**
 * Created by zhangzhuo.
 * Blog: https://blog.csdn.net/zhangzhuo1024
 * Date: 2020/5/12
 */
public class MD5Test {
    public static void main(String[] args) {

        FileMD5Utils.checkSum("app/src/sources/big_buck_bunny_720p_1mb.mkv", new FileMD5Utils.ICheckSumListener() {
            @Override
            public void onCheckFinish(String checkSum) {
                System.out.println("sources : "+checkSum);
            }
        });

        FileMD5Utils.checkSum("app/src/download/v01_v02.zip", new FileMD5Utils.ICheckSumListener() {
            @Override
            public void onCheckFinish(String checkSum) {
                System.out.println("v01_v02 : "+checkSum);
            }
        });

        FileMD5Utils.checkSum("app/src/download/big_buck_bunny.mp4", new FileMD5Utils.ICheckSumListener() {
            @Override
            public void onCheckFinish(String checkSum) {
                System.out.println("download big_buck_bunny : "+checkSum);
            }
        });
        FileMD5Utils.checkSum("app/src/google/big_buck_bunny.mp4", new FileMD5Utils.ICheckSumListener() {
            @Override
            public void onCheckFinish(String checkSum) {
                System.out.println("google big_buck_bunny : "+checkSum);
            }
        });
        FileMD5Utils.checkSum("app/src/google/11.mp4", new FileMD5Utils.ICheckSumListener() {
            @Override
            public void onCheckFinish(String checkSum) {
                System.out.println("google 11 : "+checkSum);
            }
        });
        FileMD5Utils.checkSum("app/src/download/11.mp4", new FileMD5Utils.ICheckSumListener() {
            @Override
            public void onCheckFinish(String checkSum) {
                System.out.println("download 11 : "+checkSum);
            }
        });
//
//        FileMD5Utils.checkSum("app/src/ccc/8349815a-758c-4bce-9378-4ba395b613f0.zip", new FileMD5Utils.ICheckSumListener() {
//            @Override
//            public void onCheckFinish(String checkSum) {
//                System.out.println(checkSum);
//            }
//        });

        long b = 3147483647L;
        int i = (int) b;
        System.out.println(i);
//        getAllIp();
//
//        testIntMove(2);
//
//        明明随机数();
//        String s = "";
//        s.substring(1);
//        int[] ints = {1, -2, 3, 10, -4, 7, 2, -5};
//        FindGreatestSumOfSubArray(ints);
    }
    private static void getAllIp() {
        // dos命令

        String cmd = "arp -a";

        try {

            Process process = Runtime.getRuntime().exec(cmd);

            InputStream is = process.getInputStream();

            InputStreamReader isr = new InputStreamReader(is);

            BufferedReader br = new BufferedReader(isr);

            String content = br.readLine();

            while (content != null) {

                System.out.println(content);

                content = br.readLine();

            }

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

    private static void testIntMove(int seq) {
        byte[] data2 = new byte[2];
        data2[0] = 1;
        data2[1] = 1;
        byte[] data3 = new byte[2];
        data3[0] = 1;
        data3[1] = 1;

        System.out.println(data2 == data3);
        System.out.println(data2.equals(data3));


        byte[] data = new byte[6];
        int offset = 0;
        data[offset++] = '$';
        data[offset++] = 0x11;
        data[offset++] = (byte) seq;
        data[offset++] = (byte) (seq >> 8);
        data[offset++] = (byte) (seq >> 16);
        data[offset++] = (byte) (seq >> 24);

        for (byte datum : data) {
            System.out.println(datum);
        }
    }


    private static void 明明随机数() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            TreeSet<Integer> out = new TreeSet<>();
            Integer size = Integer.valueOf(scanner.next());
            for (int i = 0; i < size; i++) {
                out.add(Integer.valueOf(scanner.next()));
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                out.forEach(x -> System.out.println(x));
            }
        }
    }

    public static int TreeDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int left = TreeDepth(root.left);
        int right = TreeDepth(root.right);
        return Math.max(left, right) + 1;
    }

    public static int FindGreatestSumOfSubArray(int[] array) {

        int result = 0;
        int length = array.length;
        for (int i = 0; i < length; i++) {
            for (int j = i + 1; j < length; j++) {
                int temp = 0;
                for (int k = i; k < j; k++) {
                    temp += array[k];
                }
                if (result < temp) {
                    result = temp;
                }
            }
        }
        return result;
    }

    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
}
